
{literal}

<script>

function getAddForm(){
		
	$.ajax({
		type: "GET",
		url: "/categories/add",
		data: {
			
		},
		success: function(data){
			showPopup(data, 'Add new category', false);
		},
		error: function(xhr, statusText, errorThrown){
			showPopup(xhr.responseText, statusText, false);
		}    
	
	});
}

function getCategoryEditForm(categoryId){
		
	$.ajax({
		type: "GET",
		url: "/categories/edit",
		data: {
			categoryId: categoryId
		},
		success: function(data){
			showPopup(data, 'Edit category', false);
		},
		error: function(xhr, statusText, errorThrown){
			showPopup(xhr.responseText, statusText, false);
		}    
	
	});
}

function deleteCategory(categoriesId){
	if (confirm('Are you sure you want to remove this category?')){
		$.ajax({
			type: "GET",
			url: "/categories/delete",
			data: {
				categoriesId : categoriesId
			},
			success: function(data){
				//showPopup(data, 'Skinshop activation', false);
				window.location.reload();
			},
			error: function(xhr, statusText, errorThrown){
				showPopup(xhr.responseText, statusText, false);
			}
	
		});
		
	}
	return false;
}
</script>

{/literal}
{strip}

<div id="content">
    <div id="content_left">
    		<div>
			<h2>CATEGORIES</h2>
		</div>

		<div>
			<a class="button_" href="#" onclick="getAddForm();">{$commonLocale->t('ADD NEW')}</a>
		</div>
		<br /><br />
		{foreach from=$categories item=c name=forU}
		<div class="admin_list">
			<div class="left">
				<div style="width : 250px; float: left;">{$c->getCategory()}</div>
				<div style="width: 150px; float: left;">
					<a href="#" onclick="getCategoryEditForm({$c->getId()});" class="button_">EDIT</a>&nbsp;
					<a href="#" onclick="deleteCategory({$c->getId()});" class="button_">DELETE</a>&nbsp;
				</div>
				
			</div>
			<div class="clear"> </div>
			
		</div>
		{/foreach}
	</div>
	<div id="content_right">
		{if $loggedUser->getIsAdministrator()}
			{include file='admin/menu.tpl'}
		{/if}
	</div>
</div>
<!-- end content  -->


{/strip}